home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 2.9 KB | 116 lines | [TEXT/CWIE] |
- /****************************************************************************************
- FontInfo.cp
-
- Copyright © 1999 Red Shed Software. All rights reserved.
- by Jonathan 'Wolf' Rentzsch (jon@redshed.net)
-
- Commenter Date Comment
- --------- ----------------- -----------------------------------------------------
- wolf Thu, Jun 24, 1999 Created.
-
- ************************************************************************************/
-
- #include "FontInfo.h"
-
- UInt16 gMaxFontHeight = 0;
- UInt16 gMaxFontWidth = 0;
-
- /****************************************************************************************
- Commenter Date Comment
- --------- ----------------- -----------------------------------------------------
- wolf Thu, Jun 24, 1999 Created.
-
- ************************************************************************************/
-
- UInt16
- GetMaxFontHeight(
- ConstStr255Param fontName,
- short size,
- StyleParameter face )
- {
- GrafPtr port;
- GetPort( &port );
- short oldFont = port->txFont;
- short oldSize = port->txSize;
- StyleField oldFace = port->txFace;
-
- short fontID;
- GetFNum( fontName, &fontID );
-
- TextFont( fontID );
- TextSize( size );
- TextFace( face );
-
- FontInfo fInfo;
- GetFontInfo( &fInfo );
-
- TextFont( oldFont );
- TextSize( oldSize );
- TextFace( oldFace );
-
- gMaxFontHeight = fInfo.ascent + fInfo.descent;
- return( gMaxFontHeight );
- }
-
- /****************************************************************************************
- Commenter Date Comment
- --------- ----------------- -----------------------------------------------------
- wolf Thu, Jun 24, 1999 Created.
-
- ************************************************************************************/
-
- UInt16
- GetMaxFontWidth(
- ConstStr255Param fontName,
- short size,
- StyleParameter face )
- {
- GrafPtr port;
- GetPort( &port );
- short oldFont = port->txFont;
- short oldSize = port->txSize;
- StyleField oldFace = port->txFace;
-
- short fontID;
- GetFNum( fontName, &fontID );
-
- TextFont( fontID );
- TextSize( size );
- TextFace( face );
-
- FontInfo fInfo;
- GetFontInfo( &fInfo );
-
- TextFont( oldFont );
- TextSize( oldSize );
- TextFace( oldFace );
-
- gMaxFontWidth = fInfo.widMax;
- return( gMaxFontWidth );
- }
-
- /****************************************************************************************
- Commenter Date Comment
- --------- ----------------- -----------------------------------------------------
- wolf Thu, Jun 24, 1999 Created.
-
- ************************************************************************************/
-
- UInt16
- GetCachedMaxFontHeight()
- {
- return( gMaxFontHeight );
- }
-
- /****************************************************************************************
- Commenter Date Comment
- --------- ----------------- -----------------------------------------------------
- wolf Thu, Jun 24, 1999 Created.
-
- ************************************************************************************/
-
- UInt16
- GetCachedMaxFontWidth()
- {
- return( gMaxFontWidth );
- }